#include<iostream>
#include<vector>
#include<queue>
#include<cstring>
#include<cmath>
#include<map>
#include<set>
#include<cstdio>
#include<algorithm>
#define debug(a) cout<<#a<<"="<<a<<endl;
using namespace std;
const int maxn=2e5+1000;
typedef long long LL;
LL a[maxn],b[maxn],c[maxn];
LL gcd(LL a,LL b)
{
	return b?gcd(b,a%b):a;
}
int main(void)
{
  cin.tie(0);std::ios::sync_with_stdio(false);
  LL n,m;cin>>n>>m;
  for(LL i=1;i<=n;i++) cin>>a[i];
  for(LL i=1;i<=n;i++) cin>>b[i];
  sort(a+1,a+1+n);
  ///c[1]=a[1];
  for(LL i=n;i>=2;i--) c[i]=a[i]-a[i-1];
  LL num=0;
  for(LL i=n;i>=2;i--){
    num=gcd(num,c[i]);
  }
  for(LL i=1;i<=m;i++){
    LL ans=gcd(a[1]+b[i],num);
    cout<<ans<<" ";
  }
  cout<<endl;
return 0;
}
